﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UniRlv.COL
{
    public static class Const
    {
        public const string FUNC_OK = "#000100#";
        public const string FUNC_CANCEL = "#000101#";
        public const string FUNC_QUERY_RLV = "#043000#";
        public const string FUNC_REMOVE = "#021000#";
        public const string FUNC_REMOVE_EMPTY = "#021001#";
        public const string FUNC_REMOVE_REMAIN = "#021002#";
        public const string FUNC_REMOVE_BATCH = "#022000#";
        public const string FUNC_RESCAN_BOX = "#023000#";
        public const string FUNC_REMOVE_PACKAGE = "#024000#";
        public const string FUNC_UNBOX_REMAIN = "#025000#";
        public const string FUNC_ZERO_REMAIN = "#026000#";
        public const string FUNC_QUERY_CODE_STATE = "#041000#";
        public const string FUNC_RESTART = "#045000#";
        public const string FUNC_CODE_SWITCH = "#031002#";
        public const string FUNC_CODE_REPLACE = "#031000#";
        public const string FUNC_CODE_IMP = "#031001#";
        public const string FUNC_RE_PRINT = "#011000#";
        public const string FUNC_SCAN_PRINT = "#011001#";
        public const string FUNC_INSERT = "#051000#";
        public const string FUNC_MANUAL_SCAN = "#052000#";
        public const string FUNC_QUERY_RLV21 = "#043001#";

        public const int FUNC_CODE_LENGTH = 8;

        public static string GetEnumString( package_state en )
        {
	        switch(en)
	        {
                case package_state.PS_NORMAL:
		        return ("整包装");
                case package_state.PS_UNBOX:
		        return ("散装");
                case package_state.PS_ZERO:
		        return ("零箱");
                case package_state.PS_MIX:
		        return ("拼箱");
                case package_state.PS_ZERO_MIX:
		        return ("零箱拼箱");
	        }

	        return ("");
        }

        public static string GetEnumString( message_type en )
        {
	        switch(en)
	        {
                case message_type.MT_LOG:
		        return ("普通");
                case message_type.MT_WARN:
		        return ("警告");
                case message_type.MT_ERROR:
		        return ("错误");
	        }

	        return ("");
        }

        public static string GetEnumString( code_state en )
        {
	        switch(en)
	        {
                case code_state.CS_UNUSE:
		        return ("未使用");
                case code_state.CS_SCANED:
		        return ("已扫描");
                case code_state.CS_PRINTED:
		        return ("已打印");
                case code_state.CS_QJ:
		        return ("已取检");
                case code_state.CS_DEL_MAN:
		        return ("手动删除");
                case code_state.CS_DEL_AUTO:
		        return ("自动删除");
                case code_state.CS_IMP:
		        return ("补码");
                case code_state.CS_DISCARDED:
		        return ("废弃");
	        }

	        return ("");
        }

        public static string GetEnumString( task_state en )
        {
	        switch(en)
	        {
                case task_state.TS_NEW:
		        return ("新建");
                case task_state.TS_PAUSE:
		        return ("暂停");
                case task_state.TS_RUN:
		        return ("运行");
                case task_state.TS_STOP:
		        return ("停止");
                case task_state.TS_VERIFIED:
		        return ("已审核");
                case task_state.TS_EXPORTED:
		        return ("已导出");
	        }

	        return ("");
        }

        public static string GetEnumString( date_unit en )
        {
	        switch(en)
	        {
                case date_unit.DU_YEAR:
		        return ("年");
                case date_unit.DU_MONTH:
		        return ("月");
                case date_unit.DU_HOUR:
		        return ("时");
                case date_unit.DU_MINUTE:
		        return ("分");
                case date_unit.DU_SECOND:
		        return ("秒");
                case date_unit.DU_DAY:
		        return ("日");
	        }

	        return ("");
        }

        public static string GetEnumString( code_usage en )
        {
	        switch(en)
	        {
                case code_usage.CU_COMMON:
		        return ("通用");
                case code_usage.CU_ONE:
		        return ("一级码");
                case code_usage.CU_TWO:
		        return ("二级码");
                case code_usage.CU_THREE:
		        return ("三级码");
                case code_usage.CU_FOUR:
		        return ("四级码");
                case code_usage.CU_AUTO:
		        return ("自动分配");
	        }

	        return ("");
        }

        public static string GetEnumString( object_state en )
        {
	        switch(en)
	        {
                case object_state.OS_UNUSED:
		        return ("停用");
                case object_state.OS_IN_USE:
		        return ("使用");
	        }

	        return ("");
        }

        public static string GetEnumString( in_device_type en )
        {
	        switch(en)
	        {
                case in_device_type.IDT_AUTO_SCANER:
		        return ("自动采集器");
                case in_device_type.IDT_MANUAL_SCANER:
		        return ("工控扫描枪");
                case in_device_type.IDT_UNI_SCANER:
		        return ("综合扫描枪");
                case in_device_type.IDT_FUNC_SCANNER:
		        return ("功能扫描枪");
                case in_device_type.IDT_BORD:
		        return ("板卡");
                case in_device_type.IDT_OCR_CAMERA:
                return ("关联码相机");
                case in_device_type.IDT_LEVEL_CAMERA:
                return "两级码采集器";
                case in_device_type.IDT_OTHERS:
                return ("输入输出采集器");
	        }

	        return ("");
        }

        public static string GetEnumString( out_device_type en )
        {
	        switch(en)
	        {
                case out_device_type.ODT_PRINTER:
		        return ("标签打印机");
                case out_device_type.ODT_DISPLAY:
		        return ("客显");
                case out_device_type.ODT_PLC:
		        return ("PLC");
                case out_device_type.ODT_BORD:
		        return ("板卡");
                case out_device_type.ODT_RELAY:
                return "继电器卡";
                case out_device_type.ODT_OTHERS:
                return ("微嵌电子板卡");
                case out_device_type.ODT_OTHERS2:
                return ("其他");
	        }

	        return ("");
        }

        public static string GetEnumString( port_type en )
        {
	        switch(en)
	        {
                case port_type.PT_COMM:
			        return ("串口");
                case port_type.PT_NET:
			        return ("网口");
                case port_type.PT_USB:
			        return ("USB");
                case port_type.PT_PARA:
			        return ("并口");
                case port_type.PT_PCI:
			        return ("PCI口");
                case port_type.PT_ISA:
			        return ("ISA口");
                case port_type.PT_PCIX:
			        return ("PCIx口");
                case port_type.PT_OTHERS:
			        return ("其他");
	        }
	        return ("");
        }

        public static string GetEnumString( exception_proccess en )
        {
	        switch(en)
	        {
                case exception_proccess.EP_LABEL_SWITCH:
		        return ("码替换");
                case exception_proccess.EP_LABEL_BATCH_DELETE:
		        return ("顺序删除码");
                case exception_proccess.EP_LABEL_PACKAGE_DELETE:
		        return ("整包装删除");
                case exception_proccess.EP_LABEL_REPRINT:
		        return ("标签重打印");
                case exception_proccess.EP_UNBOX_REMAIN:
		        return ("未包装散装[不支持]");
                case exception_proccess.EP_ZERO_REMAIN:
		        return ("未包装零箱[不支持]");
                case exception_proccess.EP_MERGE_REMAIN:
		        return ("自动拼箱[不支持]");
                case exception_proccess.EP_DELETE_REMAIN:
		        return ("未包装删除");
                case exception_proccess.EP_RESTART_TASK:
		        return ("重启任务");
                case exception_proccess.EP_LABEL_PRINT:
		        return ("标签打印");
                case exception_proccess.EP_VERIFY_TASK:
		        return ("审核任务");
                case exception_proccess.EP_QUERY_RLT:
		        return ("查询关联");
                case exception_proccess.EP_INSERT:
		        return ("插入码");
                case exception_proccess.EP_SCAN_AUTO:
		        return ("手工采集一二级码");
                case exception_proccess.EP_APPEND://手动附加尾数
		        return ("附加一级尾数");
                case exception_proccess.EP_FINISH_TASK:
                return "结束任务";
                case exception_proccess.EP_DELETE_RANGE:
                    return "范围删除";
                case exception_proccess.EP_IMPORT_DATASOURCE:
                    return "导入数据源";
            }
	        return ("");
        }

        public static string GetEnumString( post_proccess en )
        {
	        switch(en)
	        {
                case post_proccess.PP_CANCEL_RLT:
		        return ("取消所有关联");
                case post_proccess.PP_MERGE_MANUAL:
		        return ("手工拼箱");
	        }
	        return ("");
        }

        public static string GetEnumString(input_output en)
        {
            switch (en)
            {
                case input_output.INPUT:
                    return ("输入设备");
                case input_output.OUTPUT:
                    return ("输出设备");
            }
            return ("");
        }

        public static List<string> GetEnumStringArray<T>()
	    {
            Type tp = typeof(T);
            List<string> items = new List<string>();
            string item;

            if (tp == typeof(package_state))
            {
                int i = 0;
                item = GetEnumString((package_state)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((package_state)i);
                }
            }

            if (tp == typeof(message_type))
            {
                int i = 0;
                item = GetEnumString((message_type)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((message_type)i);
                }
            }

            if (tp == typeof(code_state))
            {
                int i = 0;
                item = GetEnumString((code_state)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((code_state)i);
                }
            }

            if (tp == typeof(task_state))
            {
                int i = 0;
                item = GetEnumString((task_state)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((task_state)i);
                }
            }

            if (tp == typeof(date_unit))
            {
                int i = 0;
                item = GetEnumString((date_unit)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((date_unit)i);
                }
            }

            if (tp == typeof(code_usage))
            {
                int i = 0;
                item = GetEnumString((code_usage)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((code_usage)i);
                }
            }

            if (tp == typeof(object_state))
            {
                int i = 0;
                item = GetEnumString((object_state)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((object_state)i);
                }
            }

            if (tp == typeof(in_device_type))
            {
                int i = 0;
                item = GetEnumString((in_device_type)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((in_device_type)i);
                }
            }

            if (tp == typeof(out_device_type))
            {
                int i = 0;
                item = GetEnumString((out_device_type)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((out_device_type)i);
                }
            }

            if (tp == typeof(port_type))
            {
                int i = 0;
                item = GetEnumString((port_type)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((port_type)i);
                }
            }

            if (tp == typeof(exception_proccess))
            {
                int i = 0;
                item = GetEnumString((exception_proccess)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((exception_proccess)i);
                }
            }

            if (tp == typeof(post_proccess))
            {
                int i = 0;
                item = GetEnumString((post_proccess)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((post_proccess)i);
                }
            }

            if (tp == typeof(input_output))
            {
                int i = 0;
                item = GetEnumString((input_output)i);

                while (!string.IsNullOrEmpty(item))
                {
                    items.Add(item);
                    i++;
                    item = GetEnumString((input_output)i);
                }
            }

            return items;
	    }
    }

}
